package com.jinmdz.fmis.dao.dao;

import com.jinmdz.fmis.dao.model.settlement.ChargeInvoiceItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 打印发票Dao
 *
 * @author LiCongLu
 * @date 2020-05-13 15:17
 */
public interface ChargeInvoiceDao {

    /**
     * 验证发票代码
     *
     * @param invoiceCode 发票代码
     * @return
     * @author LiCongLu
     * @date 2020-05-13 15:23
     */
    @Select(" select id from charge_invoice where invoice_code = #{invoiceCode} limit 1 ")
    @ResultType(Integer.class)
    Integer getChargeInvoiceIdByInvoiceCode(@Param("invoiceCode") String invoiceCode);

    /**
     * 验证发票号码
     *
     * @param invoiceNo 发票号码
     * @return
     * @author LiCongLu
     * @date 2020-05-13 15:23
     */
    @Select(" select id from charge_invoice where invoice_no = #{invoiceNo} limit 1 ")
    @ResultType(Integer.class)
    Integer getChargeInvoiceIdByInvoiceNo(@Param("invoiceNo") String invoiceNo);

    /**
     * 按照主键查询打印发票
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-05-14 11:10
     */
    @Select(" select id,business_code,invoice_code,invoice_no,invoice_title,invoice_charge,invoice_time" +
            " ,invoice_state_code,remark,version " +
            "  from charge_invoice where id = #{id} and deleted = 0 limit 1 ")
    ChargeInvoiceItem getChargeInvoiceById(@Param("id") Integer id);


    /**
     * 按照业务编码查询打印发票列表
     *
     * @param businessCode 业务编码
     * @return
     * @author LiCongLu
     * @date 2020-05-14 11:11
     */
    @Select(" select id,business_code,invoice_code,invoice_no,invoice_title,invoice_charge,invoice_time" +
            " ,invoice_state_code,remark,version " +
            "  from charge_invoice where business_code = #{businessCode} and deleted = 0 ")
    ArrayList<ChargeInvoiceItem> listChargeInvoiceByBusinessCode(@Param("businessCode") String businessCode);

}